package com.xlabs.client.DTO;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.xlabs.server.DO.Reply;

/**
 * Reply data transfer object class.
 */
public class ReplyDTO implements Serializable, IsSerializable, EntityDTO
{
    /**
	 * 
	 */
	private static final long serialVersionUID = 103889232191684962L;

	/**
     * The text comment.
     */
    private String replyText;

    /**
     * Key in the form of encoded string.
     */
    private String encodedKey;

    /**
     * parent's reply.
     */
    private ReplyDTO parent;
    
    /**
     * List of replies to this reply. 
     */
    private List<ReplyDTO> replies = new ArrayList<ReplyDTO>();
    
    /**
     * Number of replies to this reply.
     */
    private int replyCount;

    /**
     * createdBy.
     */
    private String createdBy;

    /**
     * createdOn.
     */
    private Date createdOn;
    
    /**
     * equals {@link Reply}{@link #createdOnIndex}
     */
    private String createdOnIndex;
    
    /**
     * Whether this reply is chosen to be the answer to its question.
     */
    private Boolean isAnswer;

    /**
     * Public constructor for GWT.
     */
    public ReplyDTO() {
    }

    /**
     * Gets comment.
     *
     * @return comment.
     */
    public String getReplyText() {
        return replyText;
    }

    /**
     * Sets Comment.
     *
     * @param replyText The text comment.
     */
    public void setReplyText(String replyText) {
        this.replyText = replyText;
    }

    /**
     * Gets encodedKey
     *
     * @return Encoded key.
     */
    public String getEncodedKey() {
        return encodedKey;
    }

    /**
     * Sets encodedKey
     *
     * @param encodedKey Encoded key
     */
    public void setEncodedKey(String encodedKey) {
        this.encodedKey = encodedKey;
    }

    /**
     * Gets parent reply, or null if there's none.
     *
     * @return parent.
     */
    public ReplyDTO getParent() {
        return parent;
    }

    /**
     * Sets parent.
     *
     * @param parent parent.
     */
    public void setParent(ReplyDTO parent) {
        this.parent = parent;
    }

    /**
     * Gets createdBy.
     * @return createdBy.
     */
    public String getCreatedBy() {
        return createdBy;
    }

    /**
     * Sets createdBy.
     * @param createdBy createdBy.
     */
    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    /**
     * Gets createdOn.
     * @return createdOn.
     */
    public Date getCreatedOn() {
        return createdOn;
    }

    /**
     * Sets createdOn.
     * @param createdOn createdOn.
     */
    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

	/**
	 * Setter for {@link #replies}
	 * @param replies list of replies to this reply.
	 */
    public void setReplies(List<ReplyDTO> replies) {
		this.replies = replies;
	}

	/**
	 * Getter for {@link #replies}
	 * @return list of replies to this reply.
	 */
    public List<ReplyDTO> getReplies() {
		return replies;
	}

	/**
	 * Adds a reply to the list of replies of this reply!
	 * @param replyDTO Reply to be added.
	 */
    public void addReply(ReplyDTO replyDTO) {
    	this.replies.add(replyDTO);
	}

	/**
	 * Sets {@link #createdOnIndex}
	 * @param createdOnIndex value of {@link #createdOnIndex}
	 */
    public void setCreatedOnIndex(String createdOnIndex)
	{
		this.createdOnIndex = createdOnIndex;
	}

	/**
	 * Gets {@link #createdOnIndex}
	 * @return Value of {@link #createdOnIndex}
	 */
    public String getCreatedOnIndex()
	{
		return createdOnIndex;
	}

	/**
	 * Sets {@link #replyCount}
	 * @param replyCount Number of replies to this reply.
	 */
    public void setReplyCount(int replyCount)
	{
		this.replyCount = replyCount;
	}

	/**
	 * Gets {@link #replyCount}
	 * @return Number of replies to this reply.
	 */
    public int getReplyCount()
	{
		return replyCount;
	}
    
    /**
     * overriding {@link Object#toString()}
     */
    public String toString()
    {
    	return replyText;
    }

	/**
	 * Setter for {@link #isAnswer}
	 * @param isAnswer the isAnswer to set
	 */
	public void setAnswer(Boolean isAnswer)
	{
		this.isAnswer = isAnswer;
	}

	/**
	 * Getter for {@link #isAnswer}
	 * @return the isAnswer
	 */
	public Boolean isAnswer()
	{
		return isAnswer;
	}
}
